package com.project.taller2.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.project.taller2.dao.ContactDAO;
import com.project.taller2.obj.Contact;
import com.project.taller2.service.ContactService;


@Service
public class ContactServiceImpl implements ContactService {

	@Autowired
	private ContactDAO contactDAO;
	
	@Transactional
	public void addContact(Contact contact) {
		contactDAO.save(contact);
	}

	@Transactional
	public List<Contact> listContacts() {
		return contactDAO.getAll();
	}

	@Transactional
	public void removeContact(Long id) {
		contactDAO.delete(contactDAO.getById(id));
	}
}
